package com.assessment.mapper;

import com.assessment.model.entity.AssessmentItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 评测项目Mapper接口
 */
public interface AssessmentItemMapper extends BaseMapper<AssessmentItem> {

    /**
     * 根据规则ID查询评测项目列表
     */
    @Select("SELECT i.* FROM t_assessment_item i " +
            "INNER JOIN t_rule_item ri ON i.id = ri.item_id " +
            "WHERE ri.rule_id = #{ruleId} AND i.deleted = 0 AND ri.deleted = 0 " +
            "ORDER BY ri.sort, i.sort")
    List<AssessmentItem> findByRuleId(@Param("ruleId") Integer ruleId);
}
